<%@page contentType="text/html" pageEncoding="GBK" session="false"%><%@page
import="org.springframework.web.context.support.WebApplicationContextUtils,
org.springframework.web.context.WebApplicationContext,
cn.pconline.passport2.*"%><%
request.setCharacterEncoding("GBK");

Passport passport = (Passport)WebApplicationContextUtils.
		getWebApplicationContext(application).getBean("passport");
cn.pconline.passport2.Session realmSession = null;

try {
	realmSession = passport.login(request, response);
} catch (TooManyPasswordWrongException tooManyPasswordWrongException) {
	request.setAttribute("username", request.getParameter("username"));
	request.setAttribute("return", request.getParameter("return"));
	request.setAttribute("wrongCount", tooManyPasswordWrongException.getWrongCount());
	pageContext.include("login_captcha.jsp");
	return;
} catch (LoginException e) {
	out.println(e.getMessage());
	return;
}

String returnUrl = request.getParameter("return");
if (returnUrl == null || returnUrl.trim().equals("")) {
	returnUrl = "index.html";
}

returnUrl = passport.buildCrossDomainRedirectUrl(request, response, realmSession, returnUrl);

%><script>location.href="<%=returnUrl %>"</script>